Added sanity check for width and height being >= 0. Also, do nothing if
authorFederico Mena Quintero <federico@helixcode.com>
Wed, 2 Feb 2000 10:05:57 +0000 (10:05 +0000)
committerArturo Espinosa <unammx@src.gnome.org>
Wed, 2 Feb 2000 10:05:57 +0000 (10:05 +0000)
2000-02-03  Federico Mena Quintero  <federico@helixcode.com>

* gdk-pixbuf/gdk-pixbuf-render.c
(gdk_pixbuf_render_threshold_alpha): Added sanity check for width
and height being >= 0.  Also, do nothing if either of them is
zero.  Thanks to Ettore for pointing this out.
(gdk_pixbuf_render_to_drawable): Likewise.
(gdk_pixbuf_render_to_drawable_alpha): Likewise.

gdk-pixbuf/ChangeLog
gdk/gdkpixbuf-render.c

index 3f74782181f6a70632ce47681b645bf9473092f4..481bb32362f8a69ebb1c4a498da84d63cbbe66a5 100644 (file)
@@ -1,3 +1,12 @@
+2000-02-03  Federico Mena Quintero  <federico@helixcode.com>
+
+       * gdk-pixbuf/gdk-pixbuf-render.c
+       (gdk_pixbuf_render_threshold_alpha): Added sanity check for width
+       and height being >= 0.  Also, do nothing if either of them is
+       zero.  Thanks to Ettore for pointing this out.
+       (gdk_pixbuf_render_to_drawable): Likewise.
+       (gdk_pixbuf_render_to_drawable_alpha): Likewise.
+
 2000-02-02  Federico Mena Quintero  <federico@helixcode.com>
 
        * gdk-pixbuf/io-gif.c (gif_get_lzw): Removed debugging g_print.
index 742e49c4c846cf7550193afa21bef5c8772c9789..19bf30deaba9593e71c3c32befc2f6fdc216fd0a 100644 (file)
@@ -68,11 +68,15 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
        g_return_if_fail (apb->bits_per_sample == 8);
 
        g_return_if_fail (bitmap != NULL);
+       g_return_if_fail (width >= 0 && height >= 0);
        g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
        g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
 
        g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
 
+       if (width == 0 || height == 0)
+               return;
+
        gc = gdk_gc_new (bitmap);
 
        if (!apb->has_alpha) {
@@ -134,6 +138,7 @@ remove_alpha (ArtPixBuf *apb, int x, int y, int width, int height, int *rowstrid
 
        g_assert (apb->n_channels == 4);
        g_assert (apb->has_alpha);
+       g_assert (width > 0 && height > 0);
        g_assert (x >= 0 && x + width <= apb->width);
        g_assert (y >= 0 && y + height <= apb->height);
 
@@ -207,9 +212,13 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
        g_return_if_fail (drawable != NULL);
        g_return_if_fail (gc != NULL);
 
+       g_return_if_fail (width >= 0 && height >= 0);
        g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
        g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
 
+       if (width == 0 || height == 0)
+               return;
+
        /* This will have to be modified once libart supports other image types.
         * Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
         * have to pack the buffer first.
@@ -287,9 +296,13 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
        g_return_if_fail (apb->bits_per_sample == 8);
 
        g_return_if_fail (drawable != NULL);
+       g_return_if_fail (width >= 0 && height >= 0);
        g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
        g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
 
+       if (width == 0 || height == 0)
+               return;
+
        gc = gdk_gc_new (drawable);
 
        if (apb->has_alpha) {